<template>
    <div class="container-content">
        <el-row>
            <el-col :span="24">
                <h3 class="panel-title">编辑库区</h3>
            </el-col>
        </el-row>
        <el-divider class="divider"></el-divider>
        <el-form
            ref="formRef"
            :model="formObject"
            label-width="100px"
            label-position="left"
            class="mt20"
        >
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="仓库区域名称">
                        <el-input v-model="formObject.regionName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="区域编码">
                        <el-input v-model="formObject.regionCode"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="状态">
                        <el-radio v-model="formObject.status" label="0" border
                            >正常</el-radio
                        >
                        <el-radio v-model="formObject.status" label="1" border
                            >停用</el-radio
                        >
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="备注">
                        <el-input
                            v-model="formObject.remark"
                            type="textarea"
                        ></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item label-width="0px">
                <el-button type="primary" @click="onSubmit">保存</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { getDetailAreaList, editAreaList } from "@/api/system/warehouse";
export default {
    data() {
        return {
            formObject: {
                createBy: "",
                createTime: "",
                regionCode: "",
                regionName: "",
                remark: "",
                id: "",
                searchValue: "",
                status: "",
                updateBy: "",
                updateTime: "",
                warehouseId: "",
            },
        };
    },
    methods: {
        onSubmit() {
            editAreaList(this.formObject).then((res) => {
                if (res.code === 200) {
                    this.$message({
                        message: "修改成功！",
                        type: "success",
                    });
                    this.$router.push({ path: "/Warehouse/Area" });
                }
            });
        },
        getData(id) {
            getDetailAreaList(id).then((res) => {
                this.formObject = res.data;
            });
        },
    },
    created() {
        this.getData(this.$route.query.id);
    },
};
</script>
<style lang="scss" scoped>
.divider {
    margin: 0;
}
</style>
